//
//  ByCellServiceGoodDetailInfo.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/11/10.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellServiceGoodDetailInfo.h"

@implementation ByCellServiceGoodDetailInfo
{
    UILabel         *_nameLabel;        // 名称
    UIView          *_tagsView;         // 标签
    UILabel         *_priceLabel;       // 现价
    UILabel         *_originPriceLabel; // 原价
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    _nameLabel = [[UILabel alloc] init];
    _nameLabel.text = @"婚庆一条龙婚庆一条龙婚庆一条龙婚庆一条龙婚庆一条龙婚庆一条龙婚庆一条龙婚庆一条龙婚庆一条龙婚庆一条龙";
    _nameLabel.numberOfLines = 0;
    _nameLabel.font = FONT(16);
    _nameLabel.textAlignment = NSTextAlignmentLeft;
    _nameLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:_nameLabel];
    
    _priceLabel = [[UILabel alloc] init];
    _priceLabel.text = @"￥88888.88";
    _priceLabel.font = FONT(20);
    _priceLabel.textAlignment = NSTextAlignmentLeft;
    _priceLabel.textColor = BY_RED_COLOR;
    [self.contentView addSubview:_priceLabel];
    
    _originPriceLabel = [[UILabel alloc] init];
    _originPriceLabel.text = @"￥99999.99";
    _originPriceLabel.font = FONT(14);
    _originPriceLabel.textAlignment = NSTextAlignmentRight;
    _originPriceLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_originPriceLabel];
    
    // 布局
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.top.equalTo(@10);
    }];
    [_originPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-10);
        make.bottom.equalTo(_priceLabel);
    }];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.top.equalTo(_priceLabel.mas_bottom).offset(5);
        make.right.equalTo(@-10);
        
        make.bottom.equalTo(self.contentView).offset(-10);
    }];
    
    // 现价
    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:_priceLabel.text];
    [attrStr addAttribute:NSFontAttributeName value:FONT(14) range:[_priceLabel.text rangeOfString:@"￥"]];
    [attrStr addAttribute:NSFontAttributeName value:FONT(14) range:NSMakeRange(_priceLabel.text.length - 2, 2)];
    _priceLabel.attributedText = attrStr;
    // 原价
    attrStr = [[NSMutableAttributedString alloc] initWithString:_originPriceLabel.text];
    [attrStr addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid|NSUnderlineStyleSingle) range:[_originPriceLabel.text rangeOfString:_originPriceLabel.text]];
    _originPriceLabel.attributedText = attrStr;
}

@end
